<style lang="less">

</style>
<template>
	<div>
		<Table
			:columns="titleName"
			:data="logsList"
			stripe/>
	</div>
</template>
<script>
import qs from 'qs';

export default {
	name: 'APILOOK',
    	props: {
		logsList: {
			type: Array,
			required: true,
		},
	},
	data() {
		return {
			titleName: [
				{
					title: 'host',
					key: 'host',
				},
				{
					title: 'api url',
					key: 'url',
				},
				{
					title: '调用api的参数',
					key: 'params',
				},
				{
					title: '调用结果是否成功',
					key: 'success',
					render: (h, { row }) => {
						let issuccess = <div>-</div>;
						if (row.success === 0) {
							issuccess = <div>成功</div>;
						} else {
							issuccess = <div>失败</div>;
						}
						return issuccess;
					},
				},
				{
					title: '调用错误原因',
					key: 'error',
				},
				{
					title: '调用日期',
					key: 'created_at',
					render: (h, { row }) => {
						let date = <div>无</div>;
						if (row.created_at) {
							// 转换后端返回的日期格式
							const d = new Date(row.created_at);

							const month = (d.getMonth() + 1) < 10 ? `0${d.getMonth() + 1}` : (d.getMonth() + 1);
							const day = d.getDate() < 10 ? `0${d.getDate()}` : d.getDate();
							const hours = d.getHours() < 10 ? `0${d.getHours()}` : d.getHours();
							const min = d.getMinutes() < 10 ? `0${d.getMinutes()}` : d.getMinutes();
							const sec = d.getSeconds() < 10 ? `0${d.getSeconds()}` : d.getSeconds();

							date = (<div>
								{d.getFullYear() }-{month }-{day } {hours}:{min}:{sec}
							</div>);
						}
						return date;
					},
				},
			],
		};
	},
	methods: {

	},
};
</script>

